package com.chushouya.order.constants;


import com.general.framework.core.enums.IEnum;

import java.util.Objects;

public enum UserOrderStatusEnum implements IEnum<Integer> {

    NEW_ORDER(0, "下单成功", "订单提交成功"),
    WAIT_CHECK(1, "待确认", "商家已确认订单"),
    CANCELLED(20, "已取消", "您的订单已取消，如有疑问请联系客服"),
    CLOSED(21, "已关闭"," 您的订单已关闭，如有疑问请联系客服"),
    TIMEOUT(22, "超时关闭", "您的订单已超时关闭，如有疑问请联系客服"),
    BACKOUT_AUDITING(23, "已取消", "您的订单已取消，如有疑问请联系客服"),
    BACKOUT_CLOSED(24, "已取消", "您的订单已取消，如有疑问请联系客服"),
    CLERK_CANCEL(25, "已取消","您的订单已取消，如有疑问请联系客服"),
    RETURN_CLOSED(26, "已取消","您的订单已取消，如有疑问请联系客服"),
    CMCC_CANCEL(27, "店员关闭","您的订单已取消，如有疑问请联系客服"),
    CHARGE_CLOSE(28, "退单关闭","您的订单已取消，如有疑问请联系客服"),
    WAIT_DELIVERY(32, "待快递发货", "等待快递发货，发货前请解锁手机并保持电量50%以上"),
    WAIT_RECEIVE(30, "待商家收货", "快递已发货，等待商家收货，确认收货后48小时内商家会完成质检"),
    WAIT_QUALITY(31, "待商家质检", "商家已收货，正在质检中,预计2个工作日完成质检"),
    WAIT_ACCEPT(40, "待工程师接单", "商家派单完成，等待工程师接单"),
    WAIT_CONFIRM(42, "待工程师确认", "工程师已接单，等待工程师上门"),
    WAIT_VISIT(41, "待工程师上门", "工程师已接单，等待工程师上门"),
    WAIT_BARGAIN(80, "商家已质检", "商家已质检，预计1个工作日内完成打款"),
    WAIT_PAY(90, "待商家打款", "商家已质检，预计1个工作日内完成打款"),

    COMPLETE(100, "已完成", "订单已完成，感谢您的支持！"),;
    private Integer value;

    private String desc;

    private String statusText;


    UserOrderStatusEnum(Integer value, String desc, String statusText) {
        this.value = value;
        this.desc = desc;
        this.statusText = statusText;
    }

    public static String getDesc(Integer status) {
        for (UserOrderStatusEnum thisEnum : UserOrderStatusEnum.values()) {
            if (Objects.equals(thisEnum.value, status)) {
                return thisEnum.desc;
            }
        }
        return UserOrderStatusEnum.WAIT_CHECK.desc;
    }

    public static UserOrderStatusEnum get(Integer status) {
        for (UserOrderStatusEnum thisEnum : UserOrderStatusEnum.values()) {
            if (Objects.equals(thisEnum.value, status)) {
                return thisEnum;
            }
        }
        return UserOrderStatusEnum.WAIT_CHECK;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }
}
